import 'package:json_annotation/json_annotation.dart';

import 'user.dart';
import 'relation.dart';
part 'hot_model.g.dart';

@JsonSerializable()
class HotModel {
  @JsonKey(defaultValue: [])
  final List<LiveModel> topLiveList;
  @JsonKey(defaultValue: [])
  final List<LiveModel> liveList;
  @JsonKey(defaultValue: [])
  final List<BannerModel> bannerList;
  @JsonKey(defaultValue: [])
  final List<LiveModel> liveRecommendList;
  @JsonKey(defaultValue: false)
  final bool rankFlag;
  @JsonKey(defaultValue: '')
  final String rankUrl;
  @JsonKey(defaultValue: '')
  final String agoraToken;

  HotModel(
      {required this.topLiveList,
      required this.liveList,
      required this.bannerList,
      required this.liveRecommendList,
      required this.rankFlag,
      required this.rankUrl,
      required this.agoraToken});

  factory HotModel.fromJson(Map<String, dynamic> json) =>
      _$HotModelFromJson(json);

  Map<String, dynamic> toJson() => _$HotModelToJson(this);
}

@JsonSerializable()
class LiveModel {
  final User? user;
  final Relation? relation;
  final Live? live;
  final ChannelInit? channelInit;
  @JsonKey(defaultValue: 0)
  final int distance;
  @JsonKey(defaultValue: '')
  final String city;
  final LiveInteractInfo? liveInteractInfo;

  const LiveModel({
    this.user,
    this.relation,
    this.live,
    this.channelInit,
    required this.distance,
    required this.city,
    this.liveInteractInfo,
  });

  factory LiveModel.fromJson(Map<String, dynamic> json) =>
      _$LiveModelFromJson(json);

  Map<String, dynamic> toJson() => _$LiveModelToJson(this);
}


@JsonSerializable()
class Live {
  @JsonKey(defaultValue: 0)
  final int lid;
  @JsonKey(defaultValue: 0)
  final int guildId;
  @JsonKey(defaultValue: 0)
  final int lshortIdId;
  @JsonKey(defaultValue: 0)
  final int uid;
  @JsonKey(defaultValue: 0)
  final int diamondSum;
  @JsonKey(defaultValue: 0)
  final int luxuriousSum;
  @JsonKey(defaultValue: 0)
  final int contributeSum;
  @JsonKey(defaultValue: 0)
  final int audienceCount;
  @JsonKey(defaultValue: '')
  final String title;
  @JsonKey(defaultValue: '')
  final String coverUrl;
  @JsonKey(defaultValue: '')
  final String rectangleCoverUrl;
  @JsonKey(defaultValue: '')
  final String rectangleCoverAbbrevUrl;
  @JsonKey(defaultValue: '')
  final String pullUrl;
  @JsonKey(defaultValue: 0)
  final int onVersion;
  @JsonKey(defaultValue: '')
  final String agoraPullStreamUrl;
  @JsonKey(defaultValue: '')
  final String tag;
  @JsonKey(defaultValue: false)
  final bool pk;
  @JsonKey(defaultValue: false)
  final bool cooperate;
  @JsonKey(defaultValue: false)
  final bool voice;
  @JsonKey(defaultValue: false)
  final bool redpack;
  @JsonKey(defaultValue: 0)
  final int charmNumber;
  @JsonKey(defaultValue: 0)
  final int type;
  @JsonKey(defaultValue: false)
  final bool onLive;
  @JsonKey(defaultValue: 0)
  final int official;
  @JsonKey(defaultValue: 0)
  final int hotValue;
  @JsonKey(defaultValue: 0)
  final double recommendScore;
  @JsonKey(defaultValue: '')
  final String dynamicCoverUrl;
  @JsonKey(defaultValue: '')
  final String dynamicCoverVideo;
  @JsonKey(defaultValue: '')
  final String liveLabelUrl;
  final SubScribeLiveTag? subScribeLiveTag;

  const Live({
    required this.lid,
    required this.guildId,
    required this.lshortIdId,
    required this.uid,
    required this.diamondSum,
    required this.luxuriousSum,
    required this.contributeSum,
    required this.audienceCount,
    required this.title,
    required this.coverUrl,
    required this.rectangleCoverUrl,
    required this.rectangleCoverAbbrevUrl,
    required this.pullUrl,
    required this.onVersion,
    required this.agoraPullStreamUrl,
    required this.tag,
    required this.pk,
    required this.cooperate,
    required this.voice,
    required this.redpack,
    required this.charmNumber,
    required this.type,
    required this.onLive,
    required this.official,
    required this.hotValue,
    required this.recommendScore,
    required this.dynamicCoverUrl,
    required this.dynamicCoverVideo,
    required this.liveLabelUrl,
    this.subScribeLiveTag,
  });

  factory Live.fromJson(Map<String, dynamic> json) => _$LiveFromJson(json);

  Map<String, dynamic> toJson() => _$LiveToJson(this);
}

@JsonSerializable()
class SubScribeLiveTag {
  @JsonKey(defaultValue: '')
  final String subscribeTagUrl;
  @JsonKey(defaultValue: '')
  final String subscribeEffectColor;

  const SubScribeLiveTag({
    required this.subscribeTagUrl,
    required this.subscribeEffectColor,
  });

  factory SubScribeLiveTag.fromJson(Map<String, dynamic> json) =>
      _$SubScribeLiveTagFromJson(json);

  Map<String, dynamic> toJson() => _$SubScribeLiveTagToJson(this);
}

@JsonSerializable()
class ChannelInit {
  @JsonKey(defaultValue: '')
  final String channel;
  @JsonKey(defaultValue: '')
  final String token;

  const ChannelInit({
    required this.channel,
    required this.token,
  });

  factory ChannelInit.fromJson(Map<String, dynamic> json) =>
      _$ChannelInitFromJson(json);

  Map<String, dynamic> toJson() => _$ChannelInitToJson(this);
}

@JsonSerializable()
class LiveInteractInfo {
  @JsonKey(defaultValue: 0)
  final int type;

  const LiveInteractInfo({
    required this.type,
  });

  factory LiveInteractInfo.fromJson(Map<String, dynamic> json) =>
      _$LiveInteractInfoFromJson(json);

  Map<String, dynamic> toJson() => _$LiveInteractInfoToJson(this);
}



@JsonSerializable()
class BannerModel {
  @JsonKey(defaultValue: '')
  final String url;
  @JsonKey(defaultValue: '')
  final String imgUrl;
  @JsonKey(defaultValue: '')
  final String app;
  @JsonKey(defaultValue: '')
  final String module;
  @JsonKey(defaultValue: 0)
  final int osType;
  @JsonKey(defaultValue: 0)
  final int webView;

  const BannerModel({
    required this.url,
    required this.imgUrl,
    required this.app,
    required this.module,
    required this.osType,
    required this.webView,
  });

  factory BannerModel.fromJson(Map<String, dynamic> json) =>
      _$BannerModelFromJson(json);

  Map<String, dynamic> toJson() => _$BannerModelToJson(this);
}


